package com.FH.organization.email_contact;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2016/12/12.
 */
@Path("/emial_contact")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class email_contactResoure {
    @EJB
    private emailContactDAO emailContactDAO;

    /**
     * GET 方法
     */
    @GET
    @Path("/{serach}&{page}&{size}")
    public ResultDTO getemailContactInfo(@PathParam("serach") String serach, @PathParam("page") String page, @PathParam("size") String size) {

        //添加分页查询
        if (null == page || "".equals(page) || "0".equals(page)) {
            page = "1";    //默认从第0行开始查起
        }
        if (null == size || "".equals(size)) {
            size = "10";  //每页默认10条数据
        }
        return emailContactDAO.getemailContactInfo(serach, page, size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addemailContactInfo(email_contactPullDTO dataDTO) {
        return emailContactDAO.addemailContactInfo(dataDTO);

    }

    /**
     * 删除
     *
     * @param dataDTO
     * @return
     */
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteemailContactInfo(email_contactPullDTO dataDTO) {
        return emailContactDAO.deleteemailContactInfo(dataDTO);
    }

    /**
     * 更新
     *
     * @param dataDTO
     * @return
     */
    @PUT
    @Path("/update")
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO updateemailContactInfo(email_contactPullDTO dataDTO) {
        return emailContactDAO.updateemailContactInfo(dataDTO);
    }

}
